﻿@using Telerik.Web.Mvc
@using Telerik.Web.Mvc.UI
@model Domain.Dto.ArticleInfoDto
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@Html.ValidationSummary(true)
@{
    var claService = Presentation.Web.Admin.PreAdminEngine.Resolve<Application.Admin.Article.IArticleClassService>();
    var allCla = claService.GetList();
    var infoClaService = Presentation.Web.Admin.PreAdminEngine.Resolve<Application.Admin.Article.IArticleInfoClassService>();
    var claId = 0;
    if (Model != null)
    {
        claId = infoClaService.GetList().Where(e => e.ArticleId == Model.Id)
            .OrderByDescending(e => e.Id).ThenByDescending(e => e.AddTime)
            .Select(e => e.ClassId).FirstOrDefault();
    }

    var sightName = "";
    if (ViewBag.sightName != null)
    {
        sightName = ViewBag.sightName;
    }
}
<div style="width: 100%; display: inline-block;">
    <div style="width: 45%; overflow: hidden; float: left; margin-right: 2%;">
        <div class="editor-label">
            <label>
                所属分类</label>
        </div>
        <select id="articleClass" name="articleClass">
            <option value="0">--请选择--</option>
            @{
                foreach (var item in allCla)
                {
                <option value = "@(item.Id)"  @(claId == item.Id ? "selected = 'selected'" : "")>@(item.Name)</option>
                }
            }
        </select>
        <div class="editor-label">
            <label>
                所属景点</label>
        </div>
        <div class="editor-label">
            <input id="sightName" name="sightName" data-autocomplete="/sight/search" class="ui-autocomplete-input"
                type="text" value="@(sightName)" />
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Title)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Title)
            @Html.ValidationMessageFor(model => model.Title)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.SubTitle)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.SubTitle)
            @Html.ValidationMessageFor(model => model.SubTitle)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.CustomDateTime)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CustomDateTime)
            @Html.ValidationMessageFor(model => model.CustomDateTime)
        </div>
    </div>
    <div style="width: 45%; overflow: hidden; float: right; margin-right: 2%;">
        <div class="editor-label">
            @Html.LabelFor(model => model.Source)
        </div>
        <div class="editor-field">
            @Html.TextBox("Source", "东部华侨城")
            @Html.ValidationMessageFor(model => model.Source)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Remark)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Remark, new { rows = "6", style = "margin-bottom:8px;" })
            @Html.ValidationMessageFor(model => model.Remark)
        </div>
        <div style="margin-bottom: 5px;">
            <label style="width: 70px;">
                过期时间</label>
        </div>
        <div class="editor-field" style="float: left">
            @Html.EditorFor(model => model.ExpiredDateTime)
            @Html.ValidationMessageFor(model => model.ExpiredDateTime)
        </div>
        <div style="float: left">
            @{
                var isNotExpired = false;
                if (Model != null && Model.ExpiredDateTime.HasValue && Model.ExpiredDateTime.Value.Year == 2100
                    && Model.ExpiredDateTime.Value.Month == 1 && Model.ExpiredDateTime.Value.Day == 1)
                {
                    isNotExpired = true;
                }
            }
            不过期<input type="checkbox" id="isNotExpired" name="isNotExpired" @(isNotExpired ? "checked='checked'":"") value="@(isNotExpired ? "1" : "0")" /></div>
    </div>
</div>
<p style="margin-top: 20px;">
    @{ 
        Html.Telerik().Editor()
        .Name("Content")
        .Encode(true)
        .HtmlAttributes(new { style = "width: 98%;height:300px;text-aligin:center; margin:10px auto auto 5px;" })
        .Value(@Html.Raw(HttpUtility.HtmlDecode(Model.Content)).ToHtmlString())
        .FileBrowser(t => t.Browse("browse", "imagebrowser")
            .Thumbnail("thumbnail", "imagebrowser")
            .Upload("upload", "imagebrowser")
            .DeleteFile("deletefile", "imagebrowser")
            .DeleteDirectory("deletedirectory", "imagebrowser")
            .CreateDirectory("createdirectory", "imagebrowser"))
        .Render();
    }
    @Html.ValidationMessageFor(model => model.Content)
</p>
<div style="display: none;">
    @Html.HiddenFor(model => model.Id);
    @Html.HiddenFor(model => model.UserId);
    @Html.HiddenFor(model => model.UserName);
    @Html.HiddenFor(model => model.IsAud);
    @Html.HiddenFor(model => model.IsDelete);
    @Html.HiddenFor(model => model.IsVouch);
    @Html.HiddenFor(model => model.IsTop);
    @Html.HiddenFor(model => model.AudTime);
    @Html.HiddenFor(model => model.DeleteTime);
    @Html.HiddenFor(model => model.VouchTime);
    @Html.HiddenFor(model => model.TopTime);
    @Html.HiddenFor(model => model.AddTime);
    @Html.HiddenFor(model => model.IpAddress);
    @Html.HiddenFor(model => model.State);
    @Html.HiddenFor(model => model.SortNum);
    @Html.HiddenFor(model => model.ViewCount);
</div>
